/**
 * 熊猫直播间初始化
 * @param page
 * @param sleep
 * @returns {Promise<object>}
 */
module.exports = async ({page, sleep}) => {
    await page.addStyleTag({
        content: `
        .room-player-login-notice,
        .time-limit-task-container,
        .lottery-container,
        .room-holday-zhuxian2-box,
        .act-zhuxianmarch-container,
        .h5player-plugins,
        .host-pk-animate-mask,
        .host-pk-opposite-follow,
        .host-pk-info,
        .room-lottery-host,
        .act-zhuxianmarch-icon,
        .act-zhuxianmarch-detail,
        .act-view-container,
        .h5player-user-play-container
            {display: none !important;}
        `
    });

    await sleep(3000);
    await page.evaluate(() => {
        localStorage.setItem('panda.tv/user/player', '{"useH5player": true}');

        const $player = document.querySelector('div.room-container');
        if ($player)
            window.scrollTo(0, $player.getBoundingClientRect().y);

        //点击播放按钮
        const $button = document.querySelector('.h5player-user-play-playbtn');
        if ($button)
            $button.click();

    });
    await sleep(2000);
};